Search the Community
Showing results for '{query}'.
Found 7,315 results
-
Certainly, adjusting colors, fonts, text sizes, etc. can be fairly easily done in user.css, to more-or-less match the appearance of the rest of the site. Even adjusting box sizes and placement can be done, to an extent. If the owner wants some picture related to a certain artist to be shown in the osC header area, that might even be possible (look at banner add-ons, or hard code changes to certain files). A full-screen store is not necessarily going to look just like the rest of the site, but you can harmonize its appearance so that it looks fairly well integrated. Once a customer has checked out, you could add a button in osC to send them back to some point on the main site (rather than having to hit "Back" multiple times). Just keep in mind that if the customer leaves osC early to jump to some other point on the main site, they may lose their session (shopping cart contents and logged-in status). If their cart is not empty when they press a button to leave the store, perhaps there could be a pop-up to confirm that they really want to do that. Also, don't write a fixed-name file with contents specifying which artist's work is to be displayed, as the most recent visitor's choice will wipe out earlier selections -- you'll need to work that into the session, or carry it along in the URL Query String. I think that jumping to an osC store as owning the entire screen, rather than trying to bend things into an iframe, modal pop-up, or whatever; will end up being easier to deal with for everyone concerned, so long as there's an easy way to jump back to the main site (navigation within osC). Per Jack's note, as normal site pages they should be properly indexed by search engines. Note that osC (Frozen) will be mobile-friendly -- does the current site use Bootstrap to behave in a similar mobile-friendly way?
-
Gary I ran into an issue with the sql lines.... date_added datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, that ran okay on one of my databases but not on another. The error given was... #1067 - Invalid default value for 'date_added' I googled that and it suggested that I needed to change the datetime to TIMESTAMP. I tried that and it created the tables but I haven't gone any further yet. I'll do that but in the meantime I thought I'd post my experience with the sql query while I remembered what happened and what I did. Okay I'm off to check out the admin area. Dan
-
[CONTRIBUTION] Ultimate SEO URLs v2.1 - by Chemo
edo.script replied to spidometrs's topic in General Add-Ons Support
I hope this will help others who are experiencing the same problem I was facing. In function __construct(){ replace all '' values for configuration_id with NULL in other words replace: 'QUERY' => "INSERT INTO `configuration` VALUES ('', 'Enable SEO URLs?', 'SEO_ENABLED', 'true', 'Enable the SEO URLs? This is a global setting and will turn them off completely.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); with 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable SEO URLs?', 'SEO_ENABLED', 'true', 'Enable the SEO URLs? This is a global setting and will turn them off completely.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); Here is the edited version: function __construct(){ $this->attributes = array(); $x = 0; $this->default_config = array(); $this->default_config['SEO_ENABLED'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable SEO URLs?', 'SEO_ENABLED', 'true', 'Enable the SEO URLs? This is a global setting and will turn them off completely.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['SEO_ADD_CID_TO_PRODUCT_URLS'] = array('DEFAULT' => 'false', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Add cPath to product URLs?', 'SEO_ADD_CID_TO_PRODUCT_URLS', 'false', 'This setting will append the cPath to the end of product URLs (i.e. - some-product-p-1.html?cPath=xx).', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['SEO_ADD_CPATH_TO_PRODUCT_URLS'] = array('DEFAULT' => 'false', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Add category parent to product URLs?', 'SEO_ADD_CPATH_TO_PRODUCT_URLS', 'false', 'This setting will append the category parent(s) name to the product URLs (i.e. - parent-some-product-p-1.html).', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['SEO_ADD_CAT_PARENT'] = array('DEFAULT' => 'false', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Add category parent to begining of URLs?', 'SEO_ADD_CAT_PARENT', 'false', 'This setting will add the category parent(s) name to the beginning of the category URLs (i.e. - parent-category-c-1.html).', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['SEO_URLS_FILTER_SHORT_WORDS'] = array('DEFAULT' => '3', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Filter Short Words', 'SEO_URLS_FILTER_SHORT_WORDS', '3', 'This setting will filter words less than or equal to the value from the URL.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)"); $x++; $this->default_config['SEO_URLS_USE_W3C_VALID'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Output W3C valid URLs (parameter string)?', 'SEO_URLS_USE_W3C_VALID', 'true', 'This setting will output W3C valid URLs.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_GLOBAL'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable SEO cache to save queries?', 'USE_SEO_CACHE_GLOBAL', 'true', 'This is a global setting and will turn off caching completely.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_PRODUCTS'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable product cache?', 'USE_SEO_CACHE_PRODUCTS', 'true', 'This will turn off caching for the products.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_CATEGORIES'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable categories cache?', 'USE_SEO_CACHE_CATEGORIES', 'true', 'This will turn off caching for the categories.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_MANUFACTURERS'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable manufacturers cache?', 'USE_SEO_CACHE_MANUFACTURERS', 'true', 'This will turn off caching for the manufacturers.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_ARTICLES'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable Articles Manager Articles cache?', 'USE_SEO_CACHE_ARTICLES', 'false', 'This will turn off caching for the Articles Manager articles.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_TOPICS'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable Articles Manager Topics cache?', 'USE_SEO_CACHE_TOPICS', 'false', 'This will turn off caching for the Articles Manager topics.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_FAQDESK_CATEGORIES'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable FAQDesk Categories cache?', 'USE_SEO_CACHE_FAQDESK_CATEGORIES', 'false', 'This will turn off caching for the FAQDesk Category pages.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_INFO_PAGES'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable Information Pages cache?', 'USE_SEO_CACHE_INFO_PAGES', 'false', 'This will turn off caching for Information Pages.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_LINKS'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable Links Manager cache?', 'USE_SEO_CACHE_LINKS', 'false', 'This will turn off caching for the Links Manager category pages.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_NEWSDESK_ARTICLES'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable NewsDesk Articles cache?', 'USE_SEO_CACHE_NEWSDESK_ARTICLES', 'false', 'This will turn off caching for the NewsDesk Article pages.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_NEWSDESK_CATEGORIES'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable NewsDesk Categories cache?', 'USE_SEO_CACHE_NEWSDESK_CATEGORIES', 'false', 'This will turn off caching for the NewsDesk Category pages.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_POLLBOOTH'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable Pollbooth cache?', 'USE_SEO_CACHE_POLLBOOTH', 'false', 'This will turn off caching for Pollbooth.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_CACHE_PAGE_EDITOR'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable Page Editor cache?', 'USE_SEO_CACHE_PAGE_EDITOR', 'false', 'This will turn off caching for the Page Editor pages.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_REDIRECT'] = array('DEFAULT' => 'true', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable automatic redirects?', 'USE_SEO_REDIRECT', 'true', 'This will activate the automatic redirect code and send 301 headers for old to new URLs.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_HEADER_TAGS'] = array('DEFAULT' => 'false', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable use Header Tags SEO as name?', 'USE_SEO_HEADER_TAGS', 'false', 'This will cause the title set in Header Tags SEO to be used instead of the categories or products name.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['USE_SEO_PERFORMANCE_CHECK'] = array('DEFAULT' => 'false', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enable performance checker?', 'USE_SEO_PERFORMANCE_CHECK', 'false', 'This will cause the code to track all database queries so that its affect on the speed of the page can be determined. Enabling it will cause a small speed loss.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['SEO_REWRITE_TYPE'] = array('DEFAULT' => 'Rewrite', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Choose URL Rewrite Type', 'SEO_REWRITE_TYPE', 'Rewrite', 'Choose which SEO URL format to use.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''Rewrite''),')"); $x++; $this->default_config['SEO_CHAR_CONVERT_SET'] = array('DEFAULT' => '', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Enter special character conversions', 'SEO_CHAR_CONVERT_SET', '', 'This setting will convert characters.<br><br>The format <b>MUST</b> be in the form: <b>char=>conv,char2=>conv2</b>', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, NULL)"); $x++; $this->default_config['SEO_REMOVE_ALL_SPEC_CHARS'] = array('DEFAULT' => 'false', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Remove all non-alphanumeric characters?', 'SEO_REMOVE_ALL_SPEC_CHARS', 'false', 'This will remove all non-letters and non-numbers. This should be handy to remove all special characters with 1 setting.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); $x++; $this->default_config['SEO_URLS_CACHE_RESET'] = array('DEFAULT' => 'false', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Reset SEO URLs Cache', 'SEO_URLS_CACHE_RESET', 'false', 'This will reset the cache data for SEO', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), 'tep_reset_cache_data_seo_urls', 'tep_cfg_select_option(array(''reset'', ''false''),')"); $x++; $this->default_config['SEO_URLS_UNINSTALL'] = array('DEFAULT' => 'false', 'QUERY' => "INSERT INTO `configuration` VALUES (NULL, 'Uninstall Ultimate SEO', 'SEO_URLS_DB_UNINSTALL', 'false', 'This will delete all of the entries in the configuration table for SEO', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), 'tep_reset_cache_data_seo_urls', 'tep_cfg_select_option(array(''uninstall'', ''false''),')"); $this->init(); } # end class constructor Similarly, in function install_settings(){ replace the '' value for configuration_group_id with NULL in other words replace: $insert_group = "INSERT INTO `configuration_group` VALUES ('', 'SEO URLs', 'Options for Ultimate SEO URLs by Chemo', '".$next_sort."', '1')"; with $insert_group = "INSERT INTO `configuration_group` VALUES (NULL, 'SEO URLs', 'Options for Ultimate SEO URLs by Chemo', '".$next_sort."', '1')"; Here is the edited version: function install_settings(){ $this->uninstall_settings(); $sort_order_query = "SELECT MAX(sort_order) as max_sort FROM `configuration_group`"; $sort = $this->DB->FetchArray( $this->DB->Query($sort_order_query) ); $next_sort = $sort['max_sort'] + 1; $insert_group = "INSERT INTO `configuration_group` VALUES (NULL, 'SEO URLs', 'Options for Ultimate SEO URLs by Chemo', '".$next_sort."', '1')"; $this->DB->Query($insert_group); $group_id = $this->DB->InsertID(); foreach ($this->default_config as $key => $value){ $sql = str_replace('GROUP_INSERT_ID', $group_id, $value['QUERY']); $this->DB->Query($sql); } $insert_cache_table = "CREATE TABLE `cache` ( `cache_id` varchar(32) NOT NULL default '', `cache_language_id` tinyint(1) NOT NULL default '0', `cache_name` varchar(255) NOT NULL default '', `cache_data` mediumtext NOT NULL, `cache_global` tinyint(1) NOT NULL default '1', `cache_gzip` tinyint(1) NOT NULL default '1', `cache_method` varchar(20) NOT NULL default 'RETURN', `cache_date` datetime NOT NULL, `cache_expires` datetime NOT NULL, PRIMARY KEY (`cache_id`,`cache_language_id`), KEY `cache_id` (`cache_id`), KEY `cache_language_id` (`cache_language_id`), KEY `cache_global` (`cache_global`) ) ;"; $this->DB->Query($insert_cache_table); } # end function Otherwise it is a great module/app. Thanks. -
improving performance by optimizing javascript loading
Karen Sloot replied to bruyndoncx's topic in Development Proposals
Some Useful Tricks To Improve JavaScript Performance 1. Use document.getElementById() Using JQuery it becomes quite easy to select DOM elements using tags, classes or ids. But this approach involves several iterations as JQuery loops through DOM elements to find a match. You can speed it up by using document.getElementById() // Using JQuery var container = $(“#container”); // Plain JavaScript var container = document.getElementById(“container”); 2.Compress your files Smaller the size of files faster it is to download them for the users, which results in faster performance. Use a compression method such as Gzip or Brotli to reduce the size of your JavaScript files 3.Minify Unwanted refers to comments, semi-colons, whitespace etc. While cumbersome refers to shortening function and variable names, reducing an if-else into ternary etc. It can be achieved with build tools like UglifyJs, Google Closure compiler or online tools like JS Compress, JS minifier etc. 4.Use mouseup instead of click Users interaction via mouse or keyboard fires several events in a specific order. It is better to bind your functionality with the mouseup event which fires before click event, this can provide performance boost especially in the older browser such as IE. This ensures that none of the interactions are missed if a user makes several mouse clicks in rapidly. 5.Cache as much as possible Caching your files in browser helps to improve the loading time of the site both for previous visitors as well as for first time users. The browser uses the locally cached copy for any pages loaded after the initial one instead of fetching them over the network. Use JavaScript service workers to cache files for offline use. Going offline gives the application feel of desktop or mobile which gives the illusion of faster app. 6.Favor native functions and constructs Rather than writing your own algorithms, it’s better to use native functions and constructs. ECMAScript provides lot of native functions like Math.floor() , Math.round(), String.prototype.match()and many others. 7. Use async and defer attributes async and defer are attributes can be added to script tags to make them either load asynchronously to the page or defer until the page has completely loaded. Using either of these attributes doesn’t block the DOM from rendering, which makes the application faster. <! — load example.js asynchronously to the page → <script src=”example.js” async></script> <! — load example.js after the page has loaded → <script src=”example.js” defer></script> 8.Recycle the DOM If you look at Facebook, Instagram, Twitter and other sites that have infinite scrolling enabled then you can understand that more and more elements are getting added to the DOM. These can cause problems since we have to now query more elements. Therefore performance decreases and browser slows down by consuming RAM. This problem can be solved by recycling DOM elements. Allocate some elements to use for displaying content to the DOM and when that elements exit the viewport, you take it back to the bottom. Complexities of an Infinite Scroller | Web | Google Developers Infinite scrollers are a common UI pattern. Here we explore how to implement this pattern in a memory conservative way…developers.google.com 9.Switch to HTTP/2 HTTP/2 is the latest version of HTTP protocol that provides some enhancements that will improve not only JavaScript performance but also improve the speed of the site in general. HTTP/2 is multiplexed which means that it handles multiple requests and responses simultaneously. 10.Animate with requestAnimationframe Animations should ideally render at 60fps(or a frame every 16.667ms) which is just perfect for human eyes. JavaScript libraries like Anime.js and GSAP are helpful for creating quick animations, but if your JavaScript animations are still running slow, try using the requestAnimationFrame() method to get them up to speed. With requestAnimationFrame, we tell the browser to call a function to render a frame. function moveLeft(){ // code to move the box to the left } window.requestAnimationFrame(moveLeft); -
MySQL query to sun quantity of products of same id
Psytanium posted a topic in PHP / SQL / Web Design
Hello, I created a group table and page in backend, now I can create groups and insert products into those groups. Can someone help me create a query to sum the quantity of products that have the same group_id ? Groups table screenshot attached. Here is the code where the query is <?php // create column list $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW, 'PRODUCT_AVAILABILITY' => PRODUCT_AVAILABILITY); asort($define_list); $column_list = array(); reset($define_list); while (list($key, $value) = each($define_list)) { if ($value > 0) $column_list[] = $key; } $select_column_list = ''; for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, p.products_size,'; break; case 'PRODUCT_LIST_NAME': $select_column_list .= 'pd.products_name, p.products_model, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, m.manufacturers_country_name, m.manufacturers_country_flag, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, p.products_incoming_quantity, (p.products_quantity + p.products_incoming_quantity) AS total_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; case 'PRODUCT_AVAILABILITY': $select_column_list .= 'p.products_availability_status, '; break; } } // show the products of a specified manufacturer if (isset($HTTP_GET_VARS['manufacturers_id']) && !empty($HTTP_GET_VARS['manufacturers_id'])) { if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) { // We are asked to show only a specific category $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.fr_currencies_id, p.products_ship_free, p.products_price, p.products_show_price, p.products_availability_status, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where " . $product_web_status . " and p.manufacturers_id = m.manufacturers_id " . $hide_brands . " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'"; } else { // We show them all $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.fr_currencies_id, p.products_ship_free, p.products_price, p.products_show_price, p.products_availability_status, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_MANUFACTURERS . " m where " . $product_web_status . " and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id " . $hide_brands . " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"; } } else { // show the products in a given categorie if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) { // We are asked to show only specific catgeory $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.fr_currencies_id, p.products_ship_free, p.products_price, p.products_show_price, p.products_availability_status, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where " . $product_web_status . " and p.manufacturers_id = m.manufacturers_id " . $hide_brands . " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'"; } else { // We show them all $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.fr_currencies_id, p.products_ship_free, p.products_price, p.products_show_price, p.products_availability_status, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where " . $product_web_status . $hide_brands . " and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'"; } } //start add 17.06.2018 DrTech76, sort by price, with currency conversion, fix $has_tax_sql=(defined("DISPLAY_PRICE_WITH_TAX") and DISPLAY_PRICE_WITH_TAX=="true");//in product_listing.php prices are always shown with tax currently, so the only determinant woulnd be the admin setting whether to take tax at the sorting level or not $has_fr_currency=(function_exists("tep_has_friendly_currency") and tep_has_friendly_currency()===true); if($has_tax_sql===true) { $parts=explode(" from ",$listing_sql); $fore=array_shift($parts); $fore.=", tmp_taxes.tax_rate"; if($has_fr_currency===true) { $fore.=", tmp_fr_curr.fr_currency_multiplier"; } foreach($parts as $ix=>$part) { if(($tpp_pos=strpos($part," ".TABLE_PRODUCTS." p "))!==false) { $tpp_pos+=strlen(" ".TABLE_PRODUCTS." p "); $fp=substr($part,0,$tpp_pos); $aft=substr($part,$tpp_pos); $price_with_tax_sql=" LEFT JOIN (SELECT tr.tax_class_id, SUM(tax_rate) AS tax_rate FROM ".TABLE_TAX_RATES." AS tr LEFT JOIN ".TABLE_ZONES_TO_GEO_ZONES." AS za ON (tr.tax_zone_id = za.geo_zone_id) LEFT JOIN ".TABLE_GEO_ZONES." AS tz ON (tz.geo_zone_id = tr.tax_zone_id) WHERE (za.zone_country_id IS NULL OR za.zone_country_id = '0' OR za.zone_country_id = '118') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '-1') GROUP BY tr.tax_class_id, tr.tax_priority) AS tmp_taxes ON (tmp_taxes.tax_class_id=p.products_tax_class_id)"; if($has_fr_currency===true) { $price_with_tax_sql.=" LEFT JOIN (SELECT currencies_id,IF(currencies_id=0 OR value=0,1,(1/value)) AS fr_currency_multiplier FROM ".TABLE_CURRENCIES." ORDER BY currencies_id) AS tmp_fr_curr ON tmp_fr_curr.currencies_id=(IF(p.fr_currencies_id NOT IN (SELECT currencies_id FROM ".TABLE_CURRENCIES."),(SELECT currencies_id FROM ".TABLE_CURRENCIES." WHERE code='".DEFAULT_CURRENCY."' LIMIT 1),p.fr_currencies_id)) "; } $part=$fp.$price_with_tax_sql.$aft; $parts[$ix]=$part; break; } } $parts=array_merge(array($fore),$parts); $listing_sql=join(" from ",$parts); $has_tax_sql=true; } else { $has_tax_sql=false; if($has_fr_currency===true) { $parts=explode(" from ",$listing_sql); $fore=array_shift($parts); $fore.=", tmp_fr_curr.fr_currency_multiplier"; foreach($parts as $ix=>$part) { if(($tpp_pos=strpos($part," ".TABLE_PRODUCTS." p "))!==false) { $tpp_pos+=strlen(" ".TABLE_PRODUCTS." p "); $fp=substr($part,0,$tpp_pos); $aft=substr($part,$tpp_pos); $price_with_curr_sql=" LEFT JOIN (SELECT currencies_id,IF(currencies_id=0 OR value=0,1,(1/value)) AS fr_currency_multiplier FROM ".TABLE_CURRENCIES." ORDER BY currencies_id) AS tmp_fr_curr ON tmp_fr_curr.currencies_id=(IF(p.fr_currencies_id NOT IN (SELECT currencies_id FROM ".TABLE_CURRENCIES."),(SELECT currencies_id FROM ".TABLE_CURRENCIES." WHERE code='".DEFAULT_CURRENCY."' LIMIT 1),p.fr_currencies_id)) "; $part=$fp.$price_with_curr_sql.$aft; $parts[$ix]=$part; break; } } $parts=array_merge(array($fore),$parts); $listing_sql=join(" from ",$parts); } } //end add 17.06.2018 DrTech76, sort by price, with currency conversion, fix if ( (!isset($HTTP_GET_VARS['sort'])) || (!preg_match('/^[1-8][ad]$/', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { if ($column_list[$i] == 'PRODUCT_LIST_PRICE') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; //start edit 17.06.2018 DrTech76, sort by price, with currency conversion, fix /* originally it was $listing_sql .= " order by products_availability_status = 1, final_price = 0, p.products_show_price = 0, final_price ASC, pd.products_name ASC"; */ if($has_tax_sql===true) { $listing_sql .= " order by products_availability_status = 1, total_quantity < 1,(final_price".(($has_fr_currency===true)?"*(IF(tmp_fr_curr.fr_currency_multiplier IS NULL,1,tmp_fr_curr.fr_currency_multiplier))":"")."*(1+(IF(p.products_tax_class_id NOT IN (SELECT tax_class_id FROM ".TABLE_TAX_CLASS."),0,(tax_rate/100))))) ".(($sort_order=='d')?'DESC':'ASC').", final_price = 0, p.products_show_price = 0, pd.products_name ASC"; } else { $listing_sql .= " order by products_availability_status = 1, total_quantity < 1,(final_price".(($has_fr_currency===true)?"*(IF(tmp_fr_curr.fr_currency_multiplier IS NULL,1,tmp_fr_curr.fr_currency_multiplier))":"").") ".(($sort_order=='d')?'DESC':'ASC').", final_price = 0, p.products_show_price = 0, pd.products_name ASC"; } //end edit 17.06.2018 DrTech76, sort by price, with currency conversion, fix break; } } } else { $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1); $sort_order = substr($HTTP_GET_VARS['sort'], 1); //start edit 17.06.2018 DrTech76, sort by price, with currency conversion, fix $sort_order=strtolower($sort_order); //end edit 17.06.2018 DrTech76, sort by price, with currency conversion, fix switch ($column_list[$sort_col-1]) { case 'PRODUCT_LIST_MODEL': $listing_sql .= " order by p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_NAME': $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : ''); break; case 'PRODUCT_LIST_MANUFACTURER': $listing_sql .= " order by m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_QUANTITY': $listing_sql .= " order by total_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_IMAGE': $listing_sql .= " order by pd.products_name"; break; case 'PRODUCT_LIST_WEIGHT': $listing_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name"; break; case 'PRODUCT_LIST_PRICE': //start edit 17.06.2018 DrTech76, sort by price, with currency conversion, fix /* originally it was $listing_sql .= " order by products_availability_status = 1, final_price = 0, p.products_show_price = 0, final_price ASC, pd.products_name ASC"; */ if($has_tax_sql===true) { $listing_sql .= " order by products_availability_status = 1, total_quantity < 1,(final_price".(($has_fr_currency===true)?"*(IF(tmp_fr_curr.fr_currency_multiplier IS NULL,1,tmp_fr_curr.fr_currency_multiplier))":"")."*(1+(IF(p.products_tax_class_id NOT IN (SELECT tax_class_id FROM ".TABLE_TAX_CLASS."),0,(tax_rate/100))))) ".(($sort_order=='d')?'DESC':'ASC').", final_price = 0, p.products_show_price = 0, pd.products_name ASC"; } else { $listing_sql .= " order by products_availability_status = 1, total_quantity < 1,(final_price".(($has_fr_currency===true)?"*(IF(tmp_fr_curr.fr_currency_multiplier IS NULL,1,tmp_fr_curr.fr_currency_multiplier))":"").") ".(($sort_order=='d')?'DESC':'ASC').", final_price = 0, p.products_show_price = 0, pd.products_name ASC"; } //end edit 17.06.2018 DrTech76, sort by price, with currency conversion, fix break; } } $catname = HEADING_TITLE; if (isset($HTTP_GET_VARS['manufacturers_id']) && !empty($HTTP_GET_VARS['manufacturers_id'])) { $image = tep_db_query("select manufacturers_image, manufacturers_name as catname from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"); $image = tep_db_fetch_array($image); $catname = $image['catname']; } elseif ($current_category_id) { $image = tep_db_query("select c.categories_image, cd.categories_name as catname from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $image = tep_db_fetch_array($image); $catname = $image['catname']; } $image2 = ''; $extraset = ''; if (TITLE_PIC == 'true'){ // Get the right image for the top-right if (isset($HTTP_GET_VARS['manufacturers_id']) && !empty($HTTP_GET_VARS['manufacturers_id'])) { $image2 = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"); $image2 = tep_db_fetch_array($image2); $image2 = $image2['manufacturers_image']; } elseif ($current_category_id) { $image2 = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'"); $image2 = tep_db_fetch_array($image2); $image2 = $image2['categories_image']; } } ?> <?php if ($image2 !=''){?><div class="title_pic"><?php echo tep_image(DIR_WS_IMAGES . $image2, $catname, '', HEADING_IMAGE_HEIGHT); ?></div><?php } ?> <?php require (DIR_WS_MODULES . 'products_filter.php');?> <?php // optional Product List Filter if (PRODUCT_LIST_FILTER > 0) { if (isset($HTTP_GET_VARS['manufacturers_id']) && !empty($HTTP_GET_VARS['manufacturers_id'])) { $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name"; } else { $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name"; } $filterlist_query = tep_db_query($filterlist_sql); if (tep_db_num_rows($filterlist_query) > 1) { echo tep_draw_form('filter', FILENAME_DEFAULT, 'get') . '<div class="show"><div>' . TEXT_SHOW . ' '; if (isset($HTTP_GET_VARS['manufacturers_id']) && !empty($HTTP_GET_VARS['manufacturers_id'])) { echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']); $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)); } else { echo tep_draw_hidden_field('cPath', $cPath); $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)); } echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']); while ($filterlist = tep_db_fetch_array($filterlist_query)) { $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']); } echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()" class="select"'); echo tep_hide_session_id() . '</div></div></form>' . "\n"; // echo '<div class="prods_hseparator">'.tep_draw_separator('spacer.gif', '1', '1').'</div>'; } } ?> <?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?> -
Hi guys, I really need to read the country from the database. Can someone help me with the query? $countries_query = tep_db_query("select ab.address_book_id as address_book_id, ab.customers_id as customers_id, ab.entry_country_id as entry_country_id, c.countries_id as countries_id, c.countries_name as countries_name from " . TABLE_ADDRESS_BOOK . " ab, " . TABLE_COUNTRIES . " c where countries_id and customers_id = '" . (int)$customer_id . "'"); $countries = tep_db_fetch_array($countries_query);
-
Hello David, The column "discount_codes" is not used by discount codes 4.4.2_BS and the discount codes 4.4.2_BS installation doesn't modify the account_history_info.php file. This code seems to be left over from another discount code add-on. Just remove " discount_codes " from the query in your account_history_info.php or revert all modifications you applied for the installation of the other discount code add-on. Meanwhile: Please post your support questions on discount codes BS in the official support forum: Discount Code BS Like this more users may see your post and help and benefit from the answers. best regards Rainer
- 13 replies
-
- discount code paypal express
- discount
-
(and 2 more)
Tagged with:
-
[CONTRIBUTION] Ultimate SEO URLs v2.1 - by Chemo
Demitry replied to spidometrs's topic in General Add-Ons Support
@Jack_mcs hi Jack, I modified my product_reviews.php file in my BS Edge install to also display individual reviews,.. same as product_reviews_info.php file did in the older osC versions, before it was dropped for whatever reason. The htaccess rewrite rules for the product_reviews.php file does not recognize any query in the url beyond products_id. Therefore, an individual review in that file with a url like this: ../product_reviews.php?products_id=19&reviews_id=3 …will ignore the last part and return the same product_reviews.php page showing all of the reviews for that product. I tried finding a solution using an htaccess RewriteRule and cannot seem to get one to work properly. I’m doing this with the assumption that I don’t need to add code in the seo.class.php class file, though I may be wrong on that. Do you or anyone else here know how to structure that RewriteRule for it to read the second part of that url query string? -
Remove 1 Product from 'Customers who bought this product also purchased' Box
JcMagpie replied to djdeuce's topic in General Support
Exclude that one product from the db query something like this, mysql_query("SELECT * FROM products WHERE productName != '$productName'"); Never used that part of the code so check the relavent file to see how to apply. -
creating loop for multiple wholesale special prices
Portman posted a topic in PHP / SQL / Web Design
Hi.... I am trying to modify my admin/specials.php file so that I can change the price for multiple "wholesale" customer groups (think SPPC) I have got it to work for a price value, but I am trying to make it work for a percentage and that is where I am coming unstuck... can someone have a look at the following code and help me out .... case 'update': $specials_id = tep_db_prepare_input($_POST['specials_id']); $products_price = tep_db_prepare_input($_POST['products_price']); $specials_price = tep_db_prepare_input($_POST['specials_price']); $expdate = tep_db_prepare_input($_POST['expdate']); // Added by peter for Wholesale special prices $array_specials_ws_price = array(); for ($i=1; $i<=MODULE_STORE_WHOLESALE_GROUPS; $i++) { $value_specials_ws_price = ['specials_price_ws_' . $i]; $wholesale_price = ("products_ws_price_$i"); $value_specials_ws_price = tep_db_prepare_input($_POST['specials_price_ws_' . $i]); if (substr($value_specials_ws_price, -1) == '%') { $new_special_ws_insert_query = tep_db_query("select products_id, products_ws_price_1 from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $new_special_ws_insert = tep_db_fetch_array($new_special_ws_insert_query); $wholesale_price_holder = $new_special_ws_insert['products_ws_price_1']; $value_specials_ws_price = ($wholesale_price_holder - (($value_specials_ws_price / 100) * $wholesale_price_holder)); } $array_specials_ws_price[] = ("specials_new_ws_price_$i = " . $value_specials_ws_price); // ********************************************************************* } $array_specials_ws_price = implode(', ', $array_specials_ws_price); // EOF Added by Peter if (substr($specials_price, -1) == '%') $specials_price = ($products_price - (($specials_price / 100) * $products_price)); $expires_date = ''; if (tep_not_null($expdate)) { $expires_date = substr($expdate, 0, 4) . substr($expdate, 5, 2) . substr($expdate, 8, 2); } // Next Line modified By Peter for Wholesale special prices tep_db_query("update " . TABLE_SPECIALS . " set specials_new_products_price = '" . tep_db_input($specials_price) . "', $array_specials_ws_price, specials_last_modified = now(), expires_date = " . (tep_not_null($expires_date) ? "'" . tep_db_input($expires_date) . "'" : 'null') . " where specials_id = '" . (int)$specials_id . "'"); tep_redirect(tep_href_link('specials.php', 'page=' . $_GET['page'] . '&sID=' . $specials_id)); break; I have simplified it a bit to try and find what I am doing wrong... my hope is to select the value in $wholesale_price in the query eventually, but for now I am querying a static field "products_ws_price_1". Basically, when I enter a percentage in the first field , but put price values in the other fields I get this error ; 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' specials_new_ws_price_2 = 32.0000, specials_new_ws_price_3 = 33.0000, specials_' at line 1 update specials set specials_new_products_price = '28.7920', specials_new_ws_price_1 = , specials_new_ws_price_2 = 32.0000, specials_new_ws_price_3 = 33.0000, specials_new_ws_price_4 = 34.0000, specials_new_ws_price_5 = 35.0000, specials_new_ws_price_6 = 36.0000, specials_new_ws_price_7 = 37.0000, specials_last_modified = now(), expires_date = '20190301' where specials_id = '6' Any help would be appreciated. -
Hello and good evening @burt - this did the trick --> Just updated the the category_tree class and put the condition query in (three times total) and it worked! (On top of the rest of changes) Great and thank you very much 🙂 Kind regards - Felix
-
Regarding the contribution: Edit pages via Admin
ArtcoInc replied to fantomen's topic in General Add-Ons Support
@fantomen As @Jack_mcs has pointed out, this add-on was written for an earlier version of osCommerce. You can adapt it to 'Frozen', but it will require a few edits to the add-on code. While I have not downloaded this add-on to examine the code, here are some of the changes you will have to make: Some time ago, Burt got rid of the filenames.php and database_tables.php files. Instead, all calls to a file, directory, or database table are now hard-coded (in both the core code, and in any add-on). You can address this in one of two ways: 1) Install the compatibility add-on http://addons.oscommerce.com/info/9506 2) Hard-code the paths into this add-on. This is not difficult to do ... probably the biggest mistake people make is that they miss one (or more) of these needed edits. (like I said, I have not downloaded this add-on, so the following example are just that ... examples. You will have to find the applicable code in your add-on) Search through the code, and wherever you find something like this: require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT); notice the names in capitol letters. You will have to change both of these: a ) Where it says DIR_WS_LANGUAGES , this was a definition in the configuration file telling where the LANGUAGES directory is. You will need to change this to the actual directory name, which in this case is languages/. b ) Where it says FILENAME_CREATE_ACCOUNT, this is where the filenames.php file defines what the CREATE_ACCOUNT file is called. You will need to change this to the actual file name, which in this case, is create_account.php. Changing both of these will result is something like this: require('languages/' . $language . '/create_account.php'); (like I said, this is just an example, and not some actual code from this add-on) So, just go through all of the code in the add-on, and search for anything with all capitol letters. If it starts with DIR_ , it is a directory name. If it starts with FILENAME_ , it is a file name. c ) In any database call, you will see something like this: $query = tep_db_query("select a.customers_id, a.customers_firstname, a.customers_lastname, b.entry_company, b.entry_city, c.zone_code from " . TABLE_CUSTOMERS . " AS a, " . TABLE_ADDRESS_BOOK . " AS b LEFT JOIN " . TABLE_ZONES . " as c ON (b.entry_zone_id = c.zone_id) WHERE a.customers_default_address_id = b.address_book_id ORDER BY entry_company,customers_lastname"); let me reformat that to be easier to read ... $query = tep_db_query("select a.customers_id, a.customers_firstname, a.customers_lastname, b.entry_company, b.entry_city, c.zone_code from " . TABLE_CUSTOMERS . " AS a, " . TABLE_ADDRESS_BOOK . " AS b LEFT JOIN " . TABLE_ZONES . " AS c ON (b.entry_zone_id = c.zone_id) WHERE a.customers_default_address_id = b.address_book_id ORDER BY entry_company, customers_lastname"); There are three entries that begin with TABLE_ . These are the database table names, and will now have to be hard coded. In this case, TABLE_CUSTOMERS refers to the customers table, TABLE_ADDRESS_BOOK refers to the address_book table, and TABLE_ZONES refers to the zones table. So, the edited command would now be: $query = tep_db_query("select a.customers_id, a.customers_firstname, a.customers_lastname, b.entry_company, b.entry_city, c.zone_code from customers AS a, address_book AS b LEFT JOIN zones AS c ON (b.entry_zone_id = c.zone_id) WHERE a.customers_default_address_id = b.address_book_id ORDER BY entry_company, customers_lastname"); (like I said, this is just an example, and not some actual code from this add-on) d ) One other coding style has changed, preparing osCommerce for newer versions of PHP. In the code, you may find something like this: $email_address = tep_db_prepare_input($HTTP_GET_VARS['email_address']); if (!@ $HTTP_POST_VARS['action']) { Whenever you see a $HTTP_POST_VARS or a $HTTP_GET_VARS, these will need to be changed to $_POST or $_GET, respectively. Please note that these changes are to make the code compatible with newer versions of PHP, and is not an indication of the add-on, or of osCommerce. If you can apply all of these changes, and get this add-on to work properly, you could then give back to the community by uploading your updated code to the add-on repository. If you find that this it too much for you to do, you can always post in the commercial portion of the forum to hire someone to do this for you. If you do do this, please pay it forward by uploading the revised code to the repository. Or, as @Jack_mcs has suggested, you could try another add-on. HTH M -
[CONTRIBUTION] Ultimate SEO URLs v2.1 - by Chemo
edo.script replied to spidometrs's topic in General Add-Ons Support
@BrockleyJohn That's a good question and frankly I had the same question in mind. And even now when everything works fine at my end I am not sure if that was the main reason. I am suspicious that something else is the main reason. Something that I haven't yet noticed, like a custom setting in MySQL or... I am using: Database: MySQL 5.6.41 with PHP Version: 5.6.30 (Zend: 2.6.0) And this is how I came to that decision. I installed older versions until I found out that Ultimate SEO 2-2.2d-14a properly inserted the SEO URL records into the configuration table and added the SEO URLs link under Admin>Configuration. So I started looking into the SQL query differences and I noticed that in Ultimate SEO 2-2.2d-14a the query is: 'QUERY' => "INSERT INTO `".TABLE_CONFIGURATION."` VALUES (NULL, 'Enable SEO URLs?', 'SEO_ENABLED', 'true', 'Enable the SEO URLs? This is a global setting and will turn them off completely.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); and in version Ultimate SEO 2-2.2d-17a, of course with other major changes in scripting, the query is changed to 'QUERY' => "INSERT INTO `configuration` VALUES ('', 'Enable SEO URLs?', 'SEO_ENABLED', 'true', 'Enable the SEO URLs? This is a global setting and will turn them off completely.', GROUP_INSERT_ID, ".$x.", NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')"); So i decided to manually try both queries in my PHP MyAdmin. The query: "INSERT INTO `configuration` VALUES ('', 'Enable SEO URLs?', 'SEO_ENABLED', 'true', 'Enable the SEO URLs? This is a global setting and will turn them off completely.', 46, 0, NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),')" returned and error: SQL query: INSERT INTO `configuration` VALUES ('', 'Enable SEO URLs111?', 'SEO_ENABLED', 'true', 'Enable the SEO URLs? This is a global setting and will turn them off completely.', 46, 0, NOW(), NOW(), NULL, 'tep_cfg_select_option(array(''true'', ''false''),') MySQL said: #1366 - Incorrect integer value: '' for column 'configuration_id' at row 1 And when I replaced the quotes with NULL the query was executed. So far that's where I am and i would much appreciate a good advise here. -
Hi, With the looming Brexit, I need to de-register for vat (I'm UK), as my relevant turnover will be under the registration threshold once EU sales are no-longer counted. When I registered a few years ago, I used the following code to switch on VAT and change my prices globally. I'd like to do the same thing to switch it off and change prices again. Down side is that I use the 'price break' and this code will not change the additional 3 pricing bands that I have. Will this code still work as an sql query, and can I 'add' anything to make it work for the price break prices too? I'm running V2.3.4. If there is an easy on/off button to globally remove vat that would be nice to know about too! thanks SQL - making all items taxable UPDATE products SET `products_tax_class_id` =2 where '2' is the number of the tax class you've previously created in admin. On changing prices shopwide - backup the products table (always wise if I've suggested anything) and then do something like for 50% hike UPDATE `products` SET `products_price` = `products_price` * 1.5 or easier to visualise UPDATE `products` SET `products_price` = `products_price` + ( `products_price` *50 /100 ) you can change the plus to a minus and the 50 to any percentage that you like or have a look at http://addons.oscommerce.com/info/4663 or for a 15% reduction UPDATE `products` SET `products_price` = `products_price` * 0.85 REMEMBER THIS WILL ONLY UPDATE YOUR MAIN PRICE IF YOU HAVE QUANTITY PRICE BREAKS OTHER PRICES WILL NOT BE CHANGED
-
Hi every one, seeking a phpadmin query to export a selected category to excel Need the following headers Need the following headers - Category, Model, Name_en, Quantity, Image, Price, Weight, Description_en, Tax Class, Manufacturer Many thanks
-
WHM/Cpanel just updated version 78 to the release channel. One of the things the Security email suggests is upgrading MySQL to 5.7 even though 5.6 is an option. So, I installed MySQL 5.7 on my local machine to test, however it didn't have "ONLY_FULL_GROUP_BY" set in the sql mode. In the interest of learning I enabled it to see what fails. With a little reading in the " MySQL 5.7 Reference Manual " I've been able to correct the queries that triggered an error. I do find it really difficult when the queries run for thousands of characters off the page. So, for me I format the query to see it better. Like this one from bm_order_history where the error was o.date_purchased wasn't included in the group by. Seems like it would be best to correct the queries rather than turning off ONLY_FULL_GROUP_BY. $orders_query = tep_db_query(" SELECT DISTINCT op.products_id, o.date_purchased FROM orders o, orders_products op, products p WHERE o.customers_id = '" . (int)$customer_id . "' AND o.orders_id = op.orders_id AND op.products_id = p.products_id AND p.products_status = '1' GROUP BY products_id, date_purchased ORDER BY o.date_purchased DESC LIMIT " . MAX_DISPLAY_PRODUCTS_IN_ORDER_HISTORY_BOX);
-
Odd cart display on products with options
JcMagpie replied to JcMagpie's topic in osCommerce Online Merchant Community Bootstrap Edition
So got it to a usable state where shop is happy with using options. First add as @puddlec stated order by pa.options_values_price to query on line 60 in public_html/includes/modules/content/product_info/cm_pi_options_attributes.php Then turns to "FALSE" in admin both Enforce Selection and Add Helper Text , then in options add " No Options Required " as a value in options and apply it to each product. You then can add the stock product directly into cart without having to touch the options select. I would think this is a change that should be made as putting a product on your site at a price that the customer can never purchase could land you in could land you in trouble with trading standards, and unless I have totaly misunderstood this bit of code it looks like stock install will give you this problem. -
Odd cart display on products with options
puddlec replied to JcMagpie's topic in osCommerce Online Merchant Community Bootstrap Edition
i added that code, to the query on line 60, and it will sort by the price so the cheapest would be the first option, instead of what order they were entered in. -
So why does my cursor get stuck in the blue box every time i try to @ someone? Jack, Twitter typeahead stopped working I and got a blank page when trying to add to cart after installing this in 2.3.4BS Gold. Both work after putting my backup database.php file in. Is this correct? return mysqli_close($$link); } function tep_db_error($query, $errno, $error) { if (OSCEH_ENABLE == 'false') { tep_db_error_Legacy($query, $errno, $error); } global $PHP_SELF; include('osc_error_handler.php'); ob_start(); debug_print_backtrace(); $traceback = ob_get_clean(); $msg = 'Query Error reported on page ' . $PHP_SELF . "\n" . 'MySQL error: ' . $errno . ' - ' . $error . "\n\n" . $query . "\n\n"; $msg .= 'URI for the page: ' . $_SERVER['REQUEST_URI'] . "\n\n"; $msg .= 'Backtrace ' . $traceback . "\n\n"; if (OSCEH_FOR_WHO == 'Email' || OSCEH_FOR_WHO == 'Both') { $email_address = (tep_not_null(OSCEH_EMAIL_ADDRESS) ? OSCEH_EMAIL_ADDRESS : STORE_OWNER_EMAIL_ADDRESS); tep_mail('Stop Notification!', $email_address, 'Critical Store Error!', $msg, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } if (OSCEH_FOR_WHO == 'Log' || OSCEH_FOR_WHO == 'Both') { OSC_ErrorHandler($msg); } $msg = '<div>Sorry something went wrong! The error has been reported to the site owner. Please try again by clicking <a href="' . tep_href_link('index.php') . '">here.</a></div>'; die($msg); } function tep_db_error_Legacy($query, $errno, $error) { if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { error_log('ERROR: [' . $errno . '] ' . $error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } die('<font color="#000000"><strong>' . $errno . ' - ' . $error . '<br /><br />' . $query . '<br /><br /><small><font color="#ff0000">[TEP STOP]</font></small><br /><br /></strong></font>'); }
-
I know you've not looked it before, was hoping you know a way to add the sql query changes without hard coding them
-
Howdy, y'all. Would someone who as experience with mysql take a look at my query for order lookup to identify why it might be causing the orders table to lock (deadlock?). I'm running a very, very modified store that started out as 2.2-MS2. I'm working on updating the site to move from php 5.4 to php 7, and optimizing/fixing errors at the same time. The live website is running mysql 5.5, and I've set up my localhost with mysql 5.7. Right now I'm trying to speed up the admin order overview page, orders.php. Currently, it takes 3-5 seconds to load. Good news is, on my localhost I modified the query to cut the load time down to .07 seconds! But the switch to php 7 won't happen for a few months, so I really want to apply this change now to the live website. I tried changing the query on the live website, but the orders table in the database locked and orders.php simply wouldn't load until I reverted the changes and had mysql restarted. Can anyone tell me why this would happen? I'm particularly hesitant to experiment because I have to contact my host to restart mysql. Old code in orders.php: if (isset($_GET['cID'])) { // query not changed here } elseif (isset($_GET['status'])) { // this query not changed either } else { $orders_query_raw = "select o.approved, o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by o.orders_id DESC"; } $orders_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $orders_query_raw, $orders_query_numrows); $orders_query = tep_db_query($orders_query_raw); New code in orders.php. $orders_query_raw is the query in question. I added $orders_query_count so that the pagination function would grab the total number of orders from there instead of from $orders_query_raw. if (isset($_GET['cID'])) { //not changed } elseif (isset($_GET['status'])) { // not changed } else { $orders_query_raw = "select o.approved, o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, y.orders_status_name, x.text as order_total from " . TABLE_ORDERS . " o left join (select * from " . TABLE_ORDERS_TOTAL . " ot where ot.class = 'ot_total') x on (o.orders_id = x.orders_id) left join (select * from " . TABLE_ORDERS_STATUS . " s where s.language_id = '" . (int)$languages_id . "' ) y on (o.orders_status = y.orders_status_id) order by o.orders_id DESC"; $orders_query_count="from orders"; } $orders_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $orders_query_raw, $orders_query_numrows, $orders_query_count); $orders_query = tep_db_query($orders_query_raw); In case helpful, this is the old code in includes/classes/split_page_results.php (this code calculates the number of pages to display for pagination, and adds the limit at the end of the raw query): function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows) { if (empty($current_page_number)) $current_page_number = 1; $pos_to = strlen($sql_query); $pos_from = strpos($sql_query, ' from', 0); $pos_group_by = strpos($sql_query, ' group by', $pos_from); if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by; $pos_having = strpos($sql_query, ' having', $pos_from); if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having; $pos_order_by = strpos($sql_query, ' order by', $pos_from); if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by; $reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, ($pos_to - $pos_from))); $reviews_count = tep_db_fetch_array($reviews_count_query); $query_num_rows = $reviews_count['total']; $num_pages = ceil($query_num_rows / $max_rows_per_page); if ($current_page_number > $num_pages) { $current_page_number = $num_pages; } $offset = ($max_rows_per_page * ($current_page_number - 1)); if ($query_num_rows > 0) $sql_query .= " limit " . $offset . ", " . $max_rows_per_page; } And new code in split_page_results.php: function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows, &$count_query='') { if (empty($current_page_number)) $current_page_number = 1; if (empty($count_query)) { $count_query = $sql_query; $pos_to = strlen($sql_query); $pos_from = strpos($sql_query, ' from', 0); $pos_group_by = strpos($sql_query, ' group by', $pos_from); if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by; $pos_having = strpos($sql_query, ' having', $pos_from); if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having; $pos_order_by = strpos($sql_query, ' order by', $pos_from); if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by; } else { $pos_to = strlen($count_query); $pos_from = 0; } $reviews_count_query = tep_db_query("select count(*) as total " . substr($count_query, $pos_from, ($pos_to - $pos_from))); $reviews_count = tep_db_fetch_array($reviews_count_query); $query_num_rows = $reviews_count['total']; $num_pages = ceil($query_num_rows / $max_rows_per_page); if ($current_page_number > $num_pages) { $current_page_number = $num_pages; } $offset = ($max_rows_per_page * ($current_page_number - 1)); if ($query_num_rows > 0) $sql_query .= " limit " . $offset . ", " . $max_rows_per_page; } Thanks for any help. First time posting here, so please let me know if there is anything I can add or change. Hopefully this is something that, once figured out, could help others with slow orders.php pages.
-
adding to specials and whats new boxes
multimixer replied to Portman's topic in PHP / SQL / Web Design
If you have a "hide_product" flag in your database, you can include that into the query, in the same way it is done for the products status where products_status = '1' and hide_product = '0' and ...... -
Hello everyone. What's wrong with this query? I get the date for account creation but all other queries remain empty. Can someone help me there ? $customers_info_query = tep_db_query("select ci.customers_id as customers_info_id, customers_info_date_of_last_logon, customers_info_number_of_logons, customers_info_date_account_created, customers_info_date_account_last_modified from " . TABLE_CUSTOMERS . " ci, " . TABLE_CUSTOMERS_INFO . " where customers_id = '" . (int)$customer_id . "'"); $customers_info = tep_db_fetch_array($customers_info_query); <?php echo '<h3>' . CATEGORY_SITEINFO . '</h3>' . ENTRY_TEXT_ACCOUNT_CREATED . ' ' . tep_date_short ($customers_info['customers_info_date_account_created']) . $separator . ENTRY_TEXT_AGREED_CONDITIONS . ' ' . $customers_info['customers_info_date_account_created'] . $separator . ENTRY_TEXT_LAST_LOGIN . ' ' . tep_date_short ($customers_info['customers_info_date_of_last_logon']) . $separator . ENTRY_TEXT_LOGIN_TOTAL . ' ' . $customers_info['customers_info_number_of_logons'] . $separator . '';?>
-
What's the htaccess code fro this please
JcMagpie replied to astoller's topic in Installation and Configuration
.htaccess can be tricky so it's best to keep a list of useful redirects #301 Redirects for .htaccess #Redirect a single page: Redirect 301 /pagename.php http://www.domain.com/pagename.html #Redirect an entire site: Redirect 301 / http://www.domain.com/ #Redirect an entire site to a sub folder Redirect 301 / http://www.domain.com/subfolder/ #Redirect a sub folder to another site Redirect 301 /subfolder http://www.domain.com/ #This will redirect any file with the .html extension to use the same filename but use the .php extension instead. RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php ## #You can also perform 301 redirects using rewriting via .htaccess. ## #Redirect from old domain to new domain RewriteEngine on RewriteBase / RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] #Redirect to www location RewriteEngine on RewriteBase / rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] #Redirect to www location with subdirectory RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} domain.com [NC] RewriteRule ^(.*)$ http://www.domain.com/directory/index.html [R=301,NC] #Redirect from old domain to new domain with full path and query string: Options +FollowSymLinks RewriteEngine On RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC] #Redirect from old domain with subdirectory to new domain w/o subdirectory including full path and query string: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI} ^/subdirname/(.*)$ RewriteRule ^(.*) http://www.katcode.com/%1 [R=302,NC] Rewrite and redirect URLs with query parameters (files placed in root directory) Original URL: http://www.example.com/index.php?id=1 Desired destination URL: http://www.example.com/path-to-new-location/ .htaccess syntax: RewriteEngine on RewriteCond %{QUERY_STRING} id=1 RewriteRule ^index\.php$ /path-to-new-location/? [L,R=301] Redirect URLs with query parameters (files placed in subdirectory) Original URL: http://www.example.com/sub-dir/index.php?id=1 Desired destination URL: http://www.example.com/path-to-new-location/ .htaccess syntax: RewriteEngine on RewriteCond %{QUERY_STRING} id=1 RewriteRule ^sub-dir/index\.php$ /path-to-new-location/? [L,R=301] Redirect one clean URL to a new clean URL Original URL: http://www.example.com/old-page/ Desired destination URL: http://www.example.com/new-page/ .htaccess syntax: RewriteEngine On RewriteRule ^old-page/?$ $1/new-page$2 [R=301,L] Rewrite and redirect URLs with query parameter to directory based structure, retaining query string in URL root level Original URL: http://www.example.com/index.php?id=100 Desired destination URL: http://www.example.com/100/ .htaccess syntax: RewriteEngine On RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA] Rewrite URLs with query parameter to directory based structure, retaining query string parameter in URL subdirectory Original URL: http://www.example.com/index.php?category=fish Desired destination URL: http://www.example.com/category/fish/ .htaccess syntax: RewriteEngine On RewriteRule ^/?category/([^/d]+)/?$ index.php?category=$1 [L,QSA] Domain change – redirect all incoming request from old to new domain (retain path) RewriteEngine on RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC] RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L] If you do not want to pass the path in the request to the new domain, change the last row to: RewriteRule ^(.*)$ http://www.example-new.com/ [R=301,L] #From blog.oldsite.com -> www.somewhere.com/blog/ retains path and query, and eliminates xtra blog path if domain is blog.oldsite.com/blog/ Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI}/ blog RewriteRule ^(.*) http://www.somewhere.com/%{REQUEST_URI} [R=302,NC] RewriteRule ^(.*) http://www.somewhere.com/blog/%{REQUEST_URI} [R=302,NC] -
Here is my contribution for 2.3.x users : Sitemap images file with "new large product images" add.* *Just 2 functions to replace in "googlesitemap/sitemap.class.php" file (from latest package v1.14a): - GenerateSitemapImages($data, $file) - GenerateImagesSitemap() 1a. Edit "sitemap.class.php" file, and find at line 682 : function GenerateImagesSitemap(){ $quotes = (defined('QUOTES_CATEGORY_NAME') ? " and customers_email_address = '' and quotes_email_address = ''" : ''); $sql = "SELECT products_id as pID, products_image as img, products_date_added as date_added, products_last_modified as last_mod, products_ordered FROM products WHERE products_status='1'" . $quotes . " ORDER BY products_ordered DESC"; if ( $products_query = tep_db_query($sql) ){ $this->debug['QUERY']['IMAGES']['STATUS'] = 'success'; $this->debug['QUERY']['IMAGES']['NUM_ROWS'] = tep_db_num_rows($products_query); $container = array(); $number = 0; $top = 0; while( $result = tep_db_fetch_array($products_query) ){ $top = max($top, $result['products_ordered']); $location = tep_href_link('product_info.php', 'products_id=' . $result['pID'], 'NONSSL', false); $location_base = $this->base_url; $lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added']; $changefreq = GOOGLE_SITEMAP_IMAGES_CHANGE_FREQ; $ratio = $top > 0 ? $result['products_ordered']/$top : 0; $priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); if ($lastmod == 0) { $lastmod = date("Y-m-d H:m:s"); } $container[] = array('loc' => htmlspecialchars(utf8_encode($location)), 'img' => htmlspecialchars(utf8_encode($location_base) . 'images/' . $result['img'] ), 'lastmod' => date ("Y-m-d", strtotime($lastmod)), 'changefreq' => $changefreq, 'priority' => $priority ); if ( sizeof($container) >= 50000 ){ $type = $number == 0 ? 'images' : 'images' . $number; $this->GenerateSitemapImages($container, $type); $container = array(); $number++; } } # end while tep_db_free_result($products_query); if ( sizeof($container) > 0 ) { $type = $number == 0 ? 'images' : 'images' . $number; return $this->GenerateSitemapImages($container, $type); } # end if } else { $this->debug['QUERY']['IMAGES']['STATUS'] = 'false'; $this->debug['QUERY']['IMAGES']['NUM_ROWS'] = '0'; } } # end function 1b. Replace with : function GenerateImagesSitemap(){ $quotes = (defined('QUOTES_CATEGORY_NAME') ? " and customers_email_address = '' and quotes_email_address = ''" : ''); $sql = "SELECT products_id as pID, products_image as img, products_date_added as date_added, products_last_modified as last_mod, products_ordered FROM products WHERE products_status='1'" . $quotes . " ORDER BY products_ordered DESC"; if ( $products_query = tep_db_query($sql) ){ $this->debug['QUERY']['IMAGES']['STATUS'] = 'success'; $this->debug['QUERY']['IMAGES']['NUM_ROWS'] = tep_db_num_rows($products_query); $pre_container = array(); $container = array(); $number = 0; $top = 0; while( $result = tep_db_fetch_array($products_query) ){ $top = max($top, $result['products_ordered']); $location = $this->hrefLink(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], $request_type, false); $location_base = $this->base_url; $lastmod = tep_not_null($result['last_mod']) ? $result['last_mod'] : $result['date_added']; $changefreq = GOOGLE_SITEMAP_IMAGES_CHANGE_FREQ; $ratio = $top > 0 ? $result['products_ordered']/$top : 0; $priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); if ($lastmod == 0) { $lastmod = date("Y-m-d H:m:s"); } $pimage_query = tep_db_query("SELECT image as pimg FROM products_images WHERE products_id = '" . $result['pID'] . "' ORDER BY sort_order ASC"); $pimg = array(); if (tep_db_num_rows($pimage_query) > 0){ $pimg = ''; while( $pimage = tep_db_fetch_array($pimage_query) ){ $pimg[] = $pimage['pimg']; } } $pre_container = array('loc' => htmlspecialchars(utf8_encode($location)), 'lastmod' => date ("Y-m-d", strtotime($lastmod)), 'changefreq' => $changefreq, 'priority' => $priority, 'img' => htmlspecialchars(utf8_encode($location_base) . 'images/' . $result['img']) ); foreach ($pimg as $key => $val ) { $pre_container['pimg_'.$key] = htmlspecialchars(utf8_encode($location_base) . 'images/' . $val); } $container[] = $pre_container; if ( sizeof($container) >= 50000 ){ $type = $number == 0 ? 'images' : 'images' . $number; $this->GenerateSitemapImages($container, $type); $container = array(); $number++; } } # end while tep_db_free_result($products_query); if ( sizeof($container) > 0 ) { $type = $number == 0 ? 'images' : 'images' . $number; return $this->GenerateSitemapImages($container, $type); } # end if } else { $this->debug['QUERY']['IMAGES']['STATUS'] = 'false'; $this->debug['QUERY']['IMAGES']['NUM_ROWS'] = '0'; } } # end function 2a. Find at line 505 : function GenerateSitemapImages($data, $file){ $content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $content .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . "\n"; $content .= 'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n"; foreach ($data as $url){ $content .= "\t" . '<url>' . "\n"; $content .= "\t\t" . '<loc>'.$url['loc'].'</loc>' . "\n"; $content .= "\t\t" . '<image:image>' . "\n"; $content .= "\t\t" . '<image:loc>' . $url['img'] . '</image:loc>' . "\n"; $content .= "\t\t" . '</image:image>' . "\n"; $content .= "\t\t" . '<lastmod>'.$url['lastmod'].'</lastmod>' . "\n"; $content .= "\t\t" . '<changefreq>'.$url['changefreq'].'</changefreq>' . "\n"; $content .= "\t\t" . '<priority>'.$url['priority'].'</priority>' . "\n"; $content .= "\t" . '</url>' . "\n"; } # end foreach $content .= '</urlset>'; return $this->SaveFile($content, $file); } # end function 2b. Replace with : function GenerateSitemapImages($data, $file){ $content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $content .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . "\n"; $content .= 'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n"; foreach ($data as $url){ $content .= "\t" . '<url>' . "\n"; $content .= "\t\t" . '<loc>'.$url['loc'].'</loc>' . "\n"; foreach ($url as $key => $val) { switch(substr($key,0,5)) { case "img": case "pimg_": $content .= "\t\t" . '<image:image>' . "\n"; $content .= "\t\t" . '<image:loc>' . $val . '</image:loc>' . "\n"; $content .= "\t\t" . '</image:image>' . "\n"; break; } } # end foreach $content .= "\t\t" . '<lastmod>'.$url['lastmod'].'</lastmod>' . "\n"; $content .= "\t\t" . '<changefreq>'.$url['changefreq'].'</changefreq>' . "\n"; $content .= "\t\t" . '<priority>'.$url['priority'].'</priority>' . "\n"; $content .= "\t" . '</url>' . "\n"; } # end foreach $content .= '</urlset>'; return $this->SaveFile($content, $file); } # end function Enjoy !
